﻿Imports System.Data.OleDb

Public Class Register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RegisterUser.ContinueDestinationPageUrl = Request.QueryString("ReturnUrl")
    End Sub

    Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)
        Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("godzillaFilms").ConnectionString)
        Dim sql As String = "INSERT INTO Profile (FanName, Picture, Rank) VALUES (@f1, @f2, @f3)"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", RegisterUser.UserName)
        cmd.Parameters.AddWithValue("@f2", "ProfilePictures/blank.jpg")
        cmd.Parameters.AddWithValue("@f3", "Mothra")
        Roles.AddUserToRole(RegisterUser.UserName, "Mothra")
        cmd.ExecuteNonQuery()
        Response.Redirect("~/AddProfile.aspx")
    End Sub
End Class